/**
 * Configuration.java
 * com.tc.client.blacktea.api
 *
 * Function： TODO 
 *
 *   ver     date      		author
 * ──────────────────────────────────
 *   		 2012-7-2 		wangjieming
 *
 * Copyright (c) 2012, TNT All Rights Reserved.
 */

package com.jamin.aabill.utils;

import java.util.Properties;
/**
 * ClassName:Configuration
 *
 * @author   wangjieming
 * @version  1.0
 * @since    v1.0
 * @Date	 2012-7-2 下午2:59:42 
 */
public class Configuration {

	private static Properties defaultProperty;

	static {
		init();
	}

	/*package*/ static void init() {
		defaultProperty = new Properties();
		defaultProperty.setProperty("blacktea.debug", "true");
		defaultProperty.setProperty("blacktea.http.connectionTimeout", "10000");
		defaultProperty.setProperty("blacktea.http.readTimeout", "10000");
		defaultProperty.setProperty("blacktea.clientVersion",Version.getVersionCode());

	}

	/**
	 * Get http:// or https://
	 * @method getScheme
	 * @return
	 * @throws 
	 * @since v1.0
	 */
	public static String getScheme(){
		return useSSL() ? "https://" : "http://";
	}

	private static boolean useSSL() {
		return getBoolean("blacktea.http.useSSL");
	}

	public static boolean getDEBUG(){
		return getBoolean("blacktea.debug");
	}
	
	public static String getCilentVersion() {
		return getProperty("blacktea.clientVersion");
	}

	public static int getConnectionTimeout() {
		return getIntProperty("blacktea.http.connectionTimeout");
	}

	public static int getReadTimeout() {
		return getIntProperty("blacktea.http.readTimeout");
	}

	private static boolean getBoolean(String name) {
		String value = getProperty(name);
		return Boolean.valueOf(value);
	}

	
	private static String getProperty(String name) {
		return defaultProperty.getProperty(name);
	}

	
	private static int getIntProperty(String name) {
		String value = getProperty(name);
		try {
			return Integer.parseInt(value);
		} catch (NumberFormatException nfe) {
			return -1;
		}
	}


}

